import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:honeypotflutter/modules/setting/page/setting_suggest/view.dart';
import 'package:honeypotflutter/public/public_get.dart';
import 'package:honeypotflutter/publicBussine/bussine_colors.dart';
import 'package:honeypotflutter/publicBussine/bussine_font.dart';
import 'package:honeypotflutter/publicBussine/bussine_image.dart';
import 'package:honeypotflutter/publicBussine/view/bussine_card.dart';
import 'package:honeypotflutter/publicBussine/view/bussine_item.dart';
import 'package:honeypotflutter/public/views/public_appBar.dart';
import 'package:honeypotflutter/public/views/public_scrollView.dart';
import 'package:honeypotflutter/router/bussine_router_url.dart';
import 'logic.dart';

class SettingPage extends StatefulWidget {
  const SettingPage({Key? key}) : super(key: key);

  @override
  State<SettingPage> createState() => _SettingPageState();
}

class _SettingPageState extends State<SettingPage> {
  final SettingLogic logic = Get.put(SettingLogic());

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: HLAppBar(navigationTitle: "设置"),
      body: HLScrollView(
        padding: EdgeInsets.only(left: 16, right: 16),
        children: [
          MGCard(
            margin: EdgeInsets.only(top: 16),
            children: [
              MGItems(
                leadTitle: "修改密码",
                trailingIcon: MGImage.image("public_next", type: ImagePathType.public),
                action: () {
                  HLGet.toNamed(MGRouterUrl.login_forget, arguments: {"sourceSetting": true});
                },
              ),
              MGItems(
                  leadTitle: "意见反馈",
                  trailingIcon: MGImage.image("public_next", type: ImagePathType.public),
                  action: () {
                    Get.to(SettingSuggestPage());
                  }),
              MGItems(
                leadTitle: "版本号",
                trailingWidget: Obx(() => Text(logic.version.value,
                    style: TextStyle(
                      fontSize: MGFont.textFont1,
                      color: MGColors.text3Color,
                    ))),
              ),
            ],
          ),
          Container(
            decoration: BoxDecoration(
              borderRadius: BorderRadius.circular(6),
              color: MGColors.whileColor,
            ),
            margin: EdgeInsets.only(top: 30),
            padding: EdgeInsets.only(top: 10, bottom: 10),
            width: double.infinity,
            child: TextButton(
                onPressed: logic.quit,
                child: Text(
                  "退出登录",
                  style: TextStyle(
                    color: MGColors.redColor,
                    fontSize: MGFont.titleFont4,
                    fontWeight: FontWeight.bold,
                  ),
                )),
          )
        ],
      ),
    );
  }

  @override
  void dispose() {
    Get.delete<SettingLogic>();
    super.dispose();
  }
}
